package org.cpoy.ei.session;

import org.cpoy.eims.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("studentCertificateLocationHome")
public class StudentCertificateLocationHome extends
		EntityHome<StudentCertificateLocation> {

	@In(create = true)
	StudentHome studentHome;
	@In(create = true)
	StudentCerficateHome studentCerficateHome;

	public void setStudentCertificateLocationId(Integer id) {
		setId(id);
	}

	public Integer getStudentCertificateLocationId() {
		return (Integer) getId();
	}

	@Override
	protected StudentCertificateLocation createInstance() {
		StudentCertificateLocation studentCertificateLocation = new StudentCertificateLocation();
		return studentCertificateLocation;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		Student student = studentHome.getDefinedInstance();
		if (student != null) {
			getInstance().setStudent(student);
		}
		StudentCerficate studentCerficate = studentCerficateHome
				.getDefinedInstance();
		if (studentCerficate != null) {
			getInstance().setStudentCerficate(studentCerficate);
		}
	}

	public boolean isWired() {
		return true;
	}

	public StudentCertificateLocation getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
